package Algorithm.DoublePointer;

import java.util.ArrayList;
import java.util.List;

// https://leetcode.cn/problems/number-of-recent-calls/
public class Leetcode933_最近的请求次数 {
    class RecentCounter {
        private List<Integer> times;
        int left;
        int right;
        public RecentCounter() {
            times = new ArrayList<>();
            left = 0;
            right = 0;
        }

        public int ping(int t) {
            times.add(t);
            right = right + 1;
            while (left < right && times.get(left) < (t - 3000)){
                left = left + 1;
            }

            return right - left;
        }
    }

}
